<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.keyword" placeholder="关键字"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getEmployees">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="handleAdd">新增</el-button>
				</el-form-item>
			</el-form>
		</el-col>




		<!--列表-->
		<el-table :data="employees" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="username" label="名称" width="180" sortable>
			</el-table-column>
			<el-table-column prop="email" label="邮箱" width="130" sortable>
			</el-table-column>
			<el-table-column prop="phone" label="电话" width="120" sortable>
			</el-table-column>
			<el-table-column prop="password" label="密码" width="120" sortable>
			</el-table-column>
			<el-table-column prop="age" label="年龄" width="120" sortable>
			</el-table-column>
			<el-table-column prop="department.name" label="部门" width="120" sortable>
			</el-table-column>
			<el-table-column prop="state" label="状态" width="100" sortable>
				<template scope="scope">
					<span style="color: green" v-if="scope.row.state ==1">正常</span>
					<span style="color: red" v-else-if="scope.row.state ==0">禁用</span>
					<span style="color: gray" v-else>未知</span>
				</template>
			</el-table-column>
			<el-table-column label="操作">
				<template scope="scope">
					<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
					<el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>


	</section>
</template>

<script>
	import { getEmployeeListPage, removeEmployee, batchRemoveEmployee, editEmployee, addEmployee } from '../../api/api';
	export default {
		data() {
			return {
                filters:{
                keyword:""
				},
                employees:[],
				total:0,
                listLoading:false
			}
		},
		methods: {

		    //展示列表
            getEmployees(){
               let para={

				};
             this.listLoading=true;
             this.$http.post("/employee",para)
				 .then(result=>{
                       result=result.data;
					 this.total=result.total;
					 this.employees=result.rows;
					 this.listLoading=false

				 })
				 .catch(result=>{

				 })
            },
            selsChange: function (sels) {
                this.sels = sels;
            },


        },
		mounted() {
            this.getEmployees()
        }
	}

</script>

<style scoped>

</style>